<div class="container-fluid">
    <h1>Subject index</h1>
    <?php
    $Subject = $viewModel->get('Subject');
    $courses = $viewModel->get('courses');
    include 'views/Include/alert.php';
    ?>
    <form class="form-horizontal" method="POST">
        <div class="control-group">
            <label class="control-label" for="inputCourseID">Courses: </label>
            <div class="controls">
                <select id="inputSubjectCourseBySch" name="courses_id">
                    <option value="-1">Select Courses</option>
                    <?php
                    foreach ($courses as $course) {
                        echo "<option value='" . $course->courses_id . "'>" . $course->courses_name . "</option>";
                    }
                    ?>
                </select>
            </div>
        </div>
    </form>
    <form action="<?php echo BASE_URL . 'subject/delete'; ?>" method="POST" onsubmit="return ConfirmChoiceDeleteMulti();">
        <a class="btn btn-primary" href="<?php echo BASE_URL . 'Subject/create' ?>">Add new</a>
        <button type="submit" class="btn btn-danger">Delete</button>
        <?php
        if ($Subject == NULL) {
            echo 'No result';
        } else {
            ?>
        <table class="table table-striped" id="tablePagination">
                <thead>
                    <tr>
                        <th></th>
                        <th>Subject ID</th>
                        <th>Subject Name</th>
                        <th>Course Name</th>
                        <th>Status</th>
                        <th>Keyword</th>
                        <th>Description</th>
                        <th>Actions</th>
                    </tr>
                </thead>
                <tbody id="subject-search">
                    <?php foreach ($Subject as $Subject) { ?>
                        <tr>
                            <td><input name="subject_id[]" type="checkbox" subject_id="checkboxsubject_id[]" value="<?php echo $Subject->subject_id; ?>"></td>
                            <td><?php echo $Subject->subject_id; ?></td>
                            <td><?php echo $Subject->subject_name; ?></td>
                            <td><?php echo $Subject->courses_name; ?></td>
                            <td><?php echo ($Subject->status == 1) ? "Active" : "Deactive"; ?></td>
                            <td><?php echo $Subject->keyword; ?></td>
                            <td><?php echo $Subject->description; ?></td>
                            <td>
                                <div class="btn-group">
                                    <a class="btn" href="<?php echo BASE_URL . 'subject/update/' . $Subject->subject_id; ?>"><i class="icon-edit"></i></a>
                                    <a class="btn" href="#" onclick="ConfirmChoiceDelete('<?php echo BASE_URL . 'Subject/delete/' . $Subject->subject_id; ?>');
                            return false;"><i class="icon-remove-sign"></i></a>
                                </div>
                            </td>
                        </tr>
                    <?php } ?>
                </tbody>
            </table>
        <?php } ?>
        <div id="smart-paginator"></div>
    </form>
</div>